<body>
	<div class="fixed hwrap">
		<a href="javascript:history.back(-1);" target="_parent" class="rel">
			<i class="icon-angle-left"></i>
		</a>
		<a href="javascript:;" target="_parent"></a>
		<h3 class="dyc">订单列表</h3>
	</div>
	<div style="height:45px;"></div>
	<div class="m_goods">
        <?php if($goodslist):?>
        <ul class="wrap" id="wrap">
            <?php foreach($goodslist as $key => $value):?>
    		<li data-id="" class="animi-fade-show">
    		  <div class="trans_head cF">
                 <span class="head_l fl"><?=$value['order_no']?><i class="rigth icon-angle-right icon-2x"></i>
					 <?php if($value['pay_status']==1 && $value['refund_status'] == 0):?>
					 	<?=c('type.fahuo_status')[$value['fahuo_status']]?>
					<?php elseif($value['refund_status'] != 0):?>
						<?=c('type.refund_status')[$value['refund_status']]?>
					<?php else:?>
						<?=c('type.pay_status')[$value['pay_status']]?>
					 <?php endif;?>
				 </span>
				 <?php if($value['fahuo_status']==1):?>
	    			 <a href="/user/goodsevaluate?id=<?=$value['id']?>">
						 <span bianji="" class="head_r fr"><?=$value['sh_status']?'查看评价':'确认收货';?></span>
					 </a>
					 <a href="https://www.kuaidi100.com/chaxun?com=<?=$value["kd_code"]?>&nu=<?=$value["kd_no"]?>" target="_blank">
						 <span bianji="" class="head_r fr">查看物流</span>
					 </a>
				 <?php endif;?>
				 <?php if($value['pay_status']==1 && $value['fahuo_status']==0 && $value['refund_status'] == 0):?>
					 <a  href='javascript:;' onclick="refundmoney(<?=$value['id']?>)">
						 <span bianji="" class="head_r fr">申请退款</span>
					 </a>
				 <?php endif;?>
    		  </div>
    		  <div class="trans_body cF">
    			<a href="/goods/detail?id=<?=$value['goods_id']?>"><img src="<?=$value['pic']?>"></a>
    			<div class="cut_body">
    			  <div class="one">
    				<dl class="dl">
    				  <dt class="myc"><?=$value['title']?></dt>
    				  <dd class="cF"><span class="fl key">￥<?=$value['goods_price_price']?></span></dd>
    				</dl>
    			  </div>
    			</div>
    		  </div>
    		</li>
            <?php endforeach;?>
    	</ul>
		<div id="loading" class="loading hide">正在加载....</div>
        <!--分页-->
       <?php else:?>
           <div class="trans_body cF" style="text-align:center;">还没有记录哦！</div>
      <?php endif;?>
    </div>
<script>
var page = 2;
$(window).scroll(function() {
	timer=null;
	if($(document).scrollTop() >= $(document).height() - $(window).height()){
		 $('#loading').show();
		 window.clearTimeout(timer);
		 $.post("/user/orderlist",{page:page},function(rs){
			if(rs.code == 0){
				if(rs.data.max_page < page){
					$('#loading').text("亲，没有更多了！").show();
					timer=window.setTimeout('$("#loading").fadeOut()',1200);
				}else{
					var html = "";
					var goodslist = rs.data.goodslist;
					for(var i = 0; i<goodslist.length;i++){
						html += '<li data-id="" class="animi-fade-show">';
			    		html += '  <div class="trans_head cF">';
			            html += '     <span class="head_l fl">' + goodslist[i].order_no + '<i class="rigth icon-angle-right icon-2x"></i></span></a>';
			    		html += '	 <a href="/user/goodsevaluate?id=' + goodslist[i].id + '"><span bianji="" class="head_r fr">评价</span></a>';
			    		html += '  </div>';
			    		html += '  <div class="trans_body cF">';
			    		html += '	<a href="/goods/detail?id=' + goodslist[i].goods_id + '"><img src="' + goodslist[i].pic + '"></a>';
			    		html += '	<div class="cut_body">';
			    		html += '	  <div class="one">';
			    		html += '		<dl class="dl">';
			    		html += '		  <dt class="myc">' + goodslist[i].title + '</dt>';
			    		html += '		  <dd class="cF"><span class="fl key">￥' + goodslist[i].goods_price_price + '</span></dd>';
			    		html += '		</dl>';
			    		html += '	  </div>';
			    		html += '	</div>';
			    		html += '  </div>';
			    		html += '</li>';
					}
					$("#wrap").append(html);
					var i = 0 ;
					var t=window.setInterval(function(){
						i++;
						if(i>5){
							i=0;
							window.clearInterval(t);
						}
					},350);
					$('#loading').hide();
					page++;
				}
			}else{
				layer.msg(rs.msg);
			}
		},"json");
	}
});

function refundmoney(id){
	layer.confirm('确认要申请退款吗?', function(index) {
		$.ajax({
			url: "/order/refundmoney",
			method: "post",
			dataType: "json",
			data: { id: id },
			success: function(res) {
				layer.msg(res.msg);
				if(res.code == 0){
					setTimeout(function(){
						window.location.reload()
					},1000);
				}
				layer.close(index);
			}
		});
	});
}

</script>
